<!doctype html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Mirchi</title>
    <script>
      function getQueryParam(param) {
        const urlParams = new URLSearchParams(window.location.search)
        return decodeURIComponent(urlParams.get(param))
      }
      window.onload = function () {
        const link = getQueryParam('title')
        if (link) {
          document.title = link
        }
      }

      function displayImage() {
        const imageUrl = getQueryParam('imgUrl')
        const img = document.getElementById('imageDisplay')
        img.onload = function () {
          document.querySelector('.loading').remove()
        }
        img.onerror = function () {
          img.style.display = 'none'
          document.querySelector('.loading').textContent = 'Image loading failed'
        }
        if (imageUrl) {
          img.src = imageUrl
        }
      }

      document.addEventListener('DOMContentLoaded', displayImage)
    </script>
  </head>

  <body>
    <img id="imageDisplay" src="" />
    <div class="loading">Loading</div>
  </body>
</html>
<style>
  body,
  html {
    margin: 0;
    padding: 0;
    height: 100%;
    overflow-x: hidden;
    overflow-y: hidden;
  }

  #imageDisplay {
    width: 100%;
    height: auto;
    display: block;
  }

  .loading {
    width: 100%;
    height: 100%;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    position: absolute;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: rgba(0, 0, 0, 0.5);
  }
</style>
